home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 13690 < prev    next >
Mailbox/MIME Entity  |  1996-08-05  |  2.0 KB

open in: MacOS 8.1     |     Win98     |     DOS

browse contents    |     view JSON data     |     view as text


This file was processed as: Mailbox/MIME Entity (archive/mbox).

ConfidenceProgramDetectionMatch TypeSupport
100% dexvert Newsgroup Content (archive/news) magic Supported
100% dexvert Mailbox/MIME Entity (archive/mbox) magic Supported
100% dexvert Internet Message Format (text/imf) magic Supported
1% dexvert Text File (text/txt) fallback Supported
100% file news, ASCII text default
100% checkBytes Printable ASCII default
100% dexmagic PrintFox/Pagefox WEAK default
100% perlTextCheck Likely Text (Perl) default
100% siegfried fmt/950 MIME Email (1.0) default
100% detectItEasy Format: plain text[LF] default (weak)
100% xdgMime message/news default



hex view
+--------+-------------------------+-------------------------+--------+--------+
|00000000| 50 61 74 68 3a 20 6e 65 | 77 73 2e 73 70 72 69 6e |Path: ne|ws.sprin|
|00000010| 74 6c 69 6e 6b 2e 6e 65 | 74 21 64 61 74 61 6c 79 |tlink.ne|t!dataly|
|00000020| 74 69 63 73 21 75 73 65 | 6e 65 74 0a 46 72 6f 6d |tics!use|net.From|
|00000030| 3a 20 52 6f 62 20 53 74 | 65 77 61 72 74 20 3c 73 |: Rob St|ewart <s|
|00000040| 74 65 77 40 64 61 74 61 | 6c 79 74 69 63 73 2e 63 |tew@data|lytics.c|
|00000050| 6f 6d 3e 0a 4e 65 77 73 | 67 72 6f 75 70 73 3a 20 |om>.News|groups: |
|00000060| 63 6f 6d 70 2e 6c 61 6e | 67 2e 63 2b 2b 0a 53 75 |comp.lan|g.c++.Su|
|00000070| 62 6a 65 63 74 3a 20 52 | 65 3a 20 77 68 65 6e 20 |bject: R|e: when |
|00000080| 74 6f 20 69 6e 68 65 72 | 69 74 2c 20 77 68 65 6e |to inher|it, when|
|00000090| 20 74 6f 20 63 6f 6d 70 | 6f 73 65 2e 2e 2e 0a 44 | to comp|ose....D|
|000000a0| 61 74 65 3a 20 54 75 65 | 2c 20 32 36 20 4d 61 72 |ate: Tue|, 26 Mar|
|000000b0| 20 31 39 39 36 20 31 37 | 3a 33 36 3a 31 39 20 2d | 1996 17|:36:19 -|
|000000c0| 30 35 30 30 0a 4f 72 67 | 61 6e 69 7a 61 74 69 6f |0500.Org|anizatio|
|000000d0| 6e 3a 20 44 61 74 61 6c | 79 74 69 63 73 2c 20 49 |n: Datal|ytics, I|
|000000e0| 6e 63 0a 4d 65 73 73 61 | 67 65 2d 49 44 3a 20 3c |nc.Messa|ge-ID: <|
|000000f0| 33 31 35 38 37 31 36 33 | 2e 31 30 34 35 40 64 61 |31587163|.1045@da|
|00000100| 74 61 6c 79 74 69 63 73 | 2e 63 6f 6d 3e 0a 52 65 |talytics|.com>.Re|
|00000110| 66 65 72 65 6e 63 65 73 | 3a 20 3c 34 6a 39 34 33 |ferences|: <4j943|
|00000120| 70 24 37 65 73 40 75 6c | 6f 77 65 6c 6c 2e 75 6d |p$7es@ul|owell.um|
|00000130| 6c 2e 65 64 75 3e 0a 4e | 4e 54 50 2d 50 6f 73 74 |l.edu>.N|NTP-Post|
|00000140| 69 6e 67 2d 48 6f 73 74 | 3a 20 32 30 34 2e 36 32 |ing-Host|: 204.62|
|00000150| 2e 32 32 34 2e 37 31 0a | 4d 69 6d 65 2d 56 65 72 |.224.71.|Mime-Ver|
|00000160| 73 69 6f 6e 3a 20 31 2e | 30 0a 43 6f 6e 74 65 6e |sion: 1.|0.Conten|
|00000170| 74 2d 54 79 70 65 3a 20 | 74 65 78 74 2f 70 6c 61 |t-Type: |text/pla|
|00000180| 69 6e 3b 20 63 68 61 72 | 73 65 74 3d 75 73 2d 61 |in; char|set=us-a|
|00000190| 73 63 69 69 0a 43 6f 6e | 74 65 6e 74 2d 54 72 61 |scii.Con|tent-Tra|
|000001a0| 6e 73 66 65 72 2d 45 6e | 63 6f 64 69 6e 67 3a 20 |nsfer-En|coding: |
|000001b0| 37 62 69 74 0a 58 2d 4d | 61 69 6c 65 72 3a 20 4d |7bit.X-M|ailer: M|
|000001c0| 6f 7a 69 6c 6c 61 20 32 | 2e 30 20 28 57 69 6e 4e |ozilla 2|.0 (WinN|
|000001d0| 54 3b 20 49 29 0a 54 6f | 3a 20 4a 6f 68 6e 20 50 |T; I).To|: John P|
|000001e0| 65 74 65 72 20 4c 65 65 | 20 3c 6a 6c 65 65 40 6a |eter Lee| <jlee@j|
|000001f0| 75 70 69 74 65 72 2e 63 | 73 2e 75 6d 6c 2e 65 64 |upiter.c|s.uml.ed|
|00000200| 75 3e 0a 0a 4a 6f 68 6e | 20 50 65 74 65 72 20 4c |u>..John| Peter L|
|00000210| 65 65 20 77 72 6f 74 65 | 3a 0a 3e 20 0a 3e 20 48 |ee wrote|:.> .> H|
|00000220| 69 3a 0a 3e 20 0a 3e 20 | 20 20 49 27 6d 20 77 6f |i:.> .> | I'm wo|
|00000230| 6e 64 65 72 69 6e 67 20 | 61 62 6f 75 74 20 61 6e |ndering |about an|
|00000240| 20 4f 4f 20 64 65 73 69 | 67 6e 2e 20 55 6e 64 65 | OO desi|gn. Unde|
|00000250| 72 20 77 68 61 74 20 63 | 69 72 63 75 6d 73 74 61 |r what c|ircumsta|
|00000260| 6e 63 65 73 20 69 73 20 | 69 74 20 6d 6f 72 65 0a |nces is |it more.|
|00000270| 3e 20 20 20 61 64 76 61 | 6e 74 61 67 65 6f 75 73 |> adva|ntageous|
|00000280| 20 74 6f 20 75 73 65 20 | 61 6e 20 69 6e 68 65 72 | to use |an inher|
|00000290| 69 74 61 6e 63 65 20 68 | 69 65 72 61 72 63 68 79 |itance h|ierarchy|
|000002a0| 20 66 6f 72 20 61 20 64 | 65 73 69 67 6e 2c 20 61 | for a d|esign, a|
|000002b0| 73 20 6f 70 70 6f 73 65 | 64 0a 3e 20 20 20 74 6f |s oppose|d.> to|
|000002c0| 20 75 73 69 6e 67 20 6f | 62 6a 65 63 74 20 63 6f | using o|bject co|
|000002d0| 6e 74 61 69 6e 6d 65 6e | 74 2c 20 61 6e 64 20 76 |ntainmen|t, and v|
|000002e0| 69 63 65 20 76 65 72 73 | 61 3f 0a 3e 20 0a 3e 20 |ice vers|a?.> .> |
|000002f0| 20 20 57 69 74 68 20 6f | 62 6a 65 63 74 20 63 6f | With o|bject co|
|00000300| 6e 74 61 69 6e 6d 65 6e | 74 3a 20 63 6c 61 73 73 |ntainmen|t: class|
|00000310| 20 22 41 22 20 68 61 73 | 20 61 20 6d 65 6d 62 65 | "A" has| a membe|
|00000320| 72 20 63 6c 61 73 73 20 | 22 42 22 20 64 65 63 6c |r class |"B" decl|
|00000330| 61 72 65 64 0a 3e 20 20 | 20 77 69 74 68 69 6e 20 |ared.> | within |
|00000340| 69 74 2e 20 41 20 61 63 | 74 73 20 61 73 20 61 20 |it. A ac|ts as a |
|00000350| 6b 69 6e 64 6f 66 20 68 | 61 6e 64 6c 65 20 63 6c |kindof h|andle cl|
|00000360| 61 73 73 20 28 49 20 74 | 68 69 6e 6b 29 20 74 68 |ass (I t|hink) th|
|00000370| 61 74 20 66 6f 72 77 61 | 72 64 73 0a 3e 20 20 20 |at forwa|rds.> |
|00000380| 72 65 71 75 65 73 74 73 | 20 74 6f 20 42 2c 20 61 |requests| to B, a|
|00000390| 6e 64 20 68 61 6e 64 6c | 65 73 20 42 27 73 20 6f |nd handl|es B's o|
|000003a0| 75 74 70 75 74 2e 0a 3e | 20 0a 3e 20 20 20 57 69 |utput..>| .> Wi|
|000003b0| 74 68 20 69 6e 68 65 72 | 69 74 61 6e 63 65 3a 20 |th inher|itance: |
|000003c0| 63 6c 61 73 73 20 22 41 | 22 20 69 73 20 61 20 62 |class "A|" is a b|
|000003d0| 61 73 65 20 63 6c 61 73 | 73 2c 20 61 6e 64 20 63 |ase clas|s, and c|
|000003e0| 6c 61 73 73 20 22 42 22 | 20 69 73 20 61 20 64 65 |lass "B"| is a de|
|000003f0| 72 69 76 65 64 0a 3e 20 | 20 20 63 6c 61 73 73 2e |rived.> | class.|
|00000400| 20 54 68 65 6e 20 41 20 | 68 61 73 20 76 69 72 74 | Then A |has virt|
|00000410| 75 61 6c 20 66 75 6e 63 | 74 69 6f 6e 73 20 74 68 |ual func|tions th|
|00000420| 61 74 20 61 72 65 20 69 | 6d 70 6c 65 6d 65 6e 74 |at are i|mplement|
|00000430| 65 64 20 69 6e 20 42 2e | 0a 3e 20 0a 3e 20 20 20 |ed in B.|.> .> |
|00000440| 2d 3e 20 41 72 65 20 74 | 68 65 72 65 20 61 6e 79 |-> Are t|here any|
|00000450| 20 67 65 6e 65 72 61 6c | 20 72 75 6c 65 73 20 6f | general| rules o|
|00000460| 66 20 74 68 75 6d 62 20 | 74 6f 20 61 70 70 6c 79 |f thumb |to apply|
|00000470| 20 68 65 72 65 3f 20 41 | 6e 79 20 6c 69 74 65 72 | here? A|ny liter|
|00000480| 61 74 75 72 65 3f 0a 3e | 20 0a 0a 54 68 65 20 6f |ature?.>| ..The o|
|00000490| 62 76 69 6f 75 73 20 6f | 6e 65 20 69 73 20 63 6f |bvious o|ne is co|
|000004a0| 72 72 65 63 74 2c 20 62 | 75 74 20 6e 6f 74 20 61 |rrect, b|ut not a|
|000004b0| 6c 77 61 79 73 20 65 61 | 73 79 20 74 6f 20 72 65 |lways ea|sy to re|
|000004c0| 63 6f 67 6e 69 7a 65 3a | 20 0a 69 6e 68 65 72 69 |cognize:| .inheri|
|000004d0| 74 61 6e 63 65 20 61 70 | 70 6c 69 65 73 20 6f 6e |tance ap|plies on|
|000004e0| 6c 79 20 77 68 65 6e 20 | 74 68 65 20 64 65 72 69 |ly when |the deri|
|000004f0| 76 65 64 20 63 6c 61 73 | 73 20 69 73 20 61 20 66 |ved clas|s is a f|
|00000500| 6f 72 6d 20 6f 66 20 74 | 68 65 20 0a 62 61 73 65 |orm of t|he .base|
|00000510| 20 63 6c 61 73 73 2c 20 | 79 6f 75 20 69 6e 68 65 | class, |you inhe|
|00000520| 72 69 74 2e 20 20 57 68 | 65 6e 20 69 74 20 6a 75 |rit. Wh|en it ju|
|00000530| 73 74 20 68 61 70 70 65 | 6e 73 20 74 6f 20 6e 65 |st happe|ns to ne|
|00000540| 65 64 20 74 6f 20 64 6f | 20 0a 74 68 69 6e 67 73 |ed to do| .things|
|00000550| 20 61 6e 6f 74 68 65 72 | 20 63 6c 61 73 73 20 6f | another| class o|
|00000560| 66 66 65 72 73 2c 20 79 | 6f 75 20 75 73 65 20 74 |ffers, y|ou use t|
|00000570| 68 65 20 6f 74 68 65 72 | 20 63 6c 61 73 73 2e 20 |he other| class. |
|00000580| 20 54 68 6f 73 65 20 61 | 72 65 20 0a 65 61 73 79 | Those a|re .easy|
|00000590| 20 73 74 61 74 65 6d 65 | 6e 74 73 20 74 6f 20 6d | stateme|nts to m|
|000005a0| 61 6b 65 2e 20 20 54 68 | 65 79 20 61 72 65 6e 27 |ake. Th|ey aren'|
|000005b0| 74 20 73 6f 20 65 61 73 | 79 20 74 6f 20 70 72 61 |t so eas|y to pra|
|000005c0| 63 74 69 63 65 2e 0a 0a | 49 74 20 72 65 61 6c 6c |ctice...|It reall|
|000005d0| 79 20 63 6f 6d 65 73 20 | 64 6f 77 6e 20 74 6f 20 |y comes |down to |
|000005e0| 64 65 63 69 64 69 6e 67 | 20 69 66 20 65 76 65 72 |deciding| if ever|
|000005f0| 79 74 68 69 6e 67 20 61 | 62 6f 75 74 20 74 68 65 |ything a|bout the|
|00000600| 20 6f 74 68 65 72 20 0a | 63 6c 61 73 73 20 69 73 | other .|class is|
|00000610| 20 6a 75 73 74 20 6c 69 | 6b 65 20 79 6f 75 72 20 | just li|ke your |
|00000620| 6e 65 77 20 63 6c 61 73 | 73 20 65 78 63 65 70 74 |new clas|s except|
|00000630| 20 79 6f 75 72 20 6e 65 | 77 20 63 6c 61 73 73 20 | your ne|w class |
|00000640| 61 64 64 73 20 61 20 0a | 66 65 77 20 74 77 69 73 |adds a .|few twis|
|00000650| 74 73 20 6f 66 20 69 74 | 73 20 6f 77 6e 2e 20 20 |ts of it|s own. |
|00000660| 54 68 69 73 20 69 73 20 | 77 68 65 6e 20 79 6f 75 |This is |when you|
|00000670| 20 75 73 65 20 69 6e 68 | 65 72 69 74 61 6e 63 65 | use inh|eritance|
|00000680| 2e 20 20 49 66 20 0a 74 | 68 65 20 6f 74 68 65 72 |. If .t|he other|
|00000690| 20 63 6c 61 73 73 20 68 | 61 73 20 74 68 69 6e 67 | class h|as thing|
|000006a0| 73 20 74 68 61 74 20 61 | 72 65 6e 27 74 20 72 65 |s that a|ren't re|
|000006b0| 61 6c 6c 79 20 72 69 67 | 68 74 20 66 6f 72 20 79 |ally rig|ht for y|
|000006c0| 6f 75 72 20 6e 65 77 20 | 0a 63 6c 61 73 73 2c 20 |our new |.class, |
|000006d0| 74 68 65 6e 20 79 6f 75 | 20 70 72 6f 62 61 62 6c |then you| probabl|
|000006e0| 79 20 6e 65 65 64 20 74 | 6f 20 75 73 65 20 74 68 |y need t|o use th|
|000006f0| 65 20 6f 74 68 65 72 20 | 63 6c 61 73 73 2e 20 20 |e other |class. |
|00000700| 48 6f 77 65 76 65 72 2c | 20 0a 79 6f 75 20 6d 69 |However,| .you mi|
|00000710| 67 68 74 20 61 6c 73 6f | 20 77 61 6e 74 20 74 6f |ght also| want to|
|00000720| 20 63 6f 6e 73 69 64 65 | 72 20 63 72 65 61 74 69 | conside|r creati|
|00000730| 6e 67 20 61 20 63 6f 6d | 6d 6f 6e 20 62 61 73 65 |ng a com|mon base|
|00000740| 20 63 6c 61 73 73 20 73 | 6f 20 0a 74 68 61 74 20 | class s|o .that |
|00000750| 79 6f 75 72 20 6e 65 77 | 20 63 6c 61 73 73 20 61 |your new| class a|
|00000760| 6e 64 20 74 68 61 74 20 | 6f 74 68 65 72 20 63 6c |nd that |other cl|
|00000770| 61 73 73 20 64 65 72 69 | 76 65 20 66 72 6f 6d 20 |ass deri|ve from |
|00000780| 69 74 2e 0a 0a 44 69 64 | 20 74 68 69 73 20 68 65 |it...Did| this he|
|00000790| 6c 70 20 61 6e 79 3f 0a | 0a 2d 2d 20 0a 52 6f 62 |lp any?.|.-- .Rob|
|000007a0| 65 72 74 20 53 74 65 77 | 61 72 74 09 09 7c 20 4d |ert Stew|art..| M|
|000007b0| 79 20 6f 70 69 6e 69 6f | 6e 73 20 61 72 65 20 75 |y opinio|ns are u|
|000007c0| 73 75 61 6c 6c 79 20 6d | 79 20 6f 77 6e 2e 0a 44 |sually m|y own..D|
|000007d0| 61 74 61 6c 79 74 69 63 | 73 2c 20 49 6e 63 2e 09 |atalytic|s, Inc..|
|000007e0| 7c 20 73 74 65 77 40 64 | 61 74 61 6c 79 74 69 63 || stew@d|atalytic|
|000007f0| 73 2e 63 6f 6d 0a | |s.com. | |
+--------+-------------------------+-------------------------+--------+--------+